package com.avic.rong.goodsSort.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.avic.rong.R;

import java.util.List;


/**
 * Created by Chenjiaxin on 2019/7/15 14:20
 * E-Mail Address：16601203965@163.com
 */
public class GoodsBzVpAdapter extends FragmentPagerAdapter {

    private List<String> titleList;
    private List<Fragment> fragmentList;
    private Context context;
    private LayoutInflater inflater;

    public GoodsBzVpAdapter(FragmentManager fm, List<String> titleList, List<Fragment> fragmentList, Context context) {
        super(fm);
        this.titleList = titleList;
        this.fragmentList = fragmentList;
        this.context = context;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public Fragment getItem(int i) {
        return fragmentList.get(i);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titleList.get(position);
    }
    //    public GoodsBzVpAdapter(List<String> titleList, Context context,List<Fragment> fragmentList) {
//        super();
//        this.titleList = titleList;
//        this.context = context;
//        this.fragmentList = fragmentList;
//        this.inflater = LayoutInflater.from(context);
//    }

//    @Override
//    public int getCount() {
//        return titleList.size();
//    }
//
//    @Override
//    public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
//        return view == o;
//    }
//
//    @Override
//    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
//        container.removeView((View) object);
//    }
//
//    @Nullable
//    @Override
//    public CharSequence getPageTitle(int position) {
//        return titleList.get(position);
//    }
//
//    @Override
//    public Fragment getItem(int i) {
//        return fragmentList.get(i);
//    }

//    @NonNull
//    @Override
//    public Object instantiateItem(@NonNull ViewGroup container, int position) {
//        Fragment view = fragmentList.get(position);
//        RecyclerView rv = view.findViewById(R.id.goods_Bz_Rv);
//        initData();
//        if (position == 0){
//            adapterDuo = new GoodsBzRvAdapter(beanList,context);
//            rv.setLayoutManager(new LinearLayoutManager(context));
//            rv.setAdapter(adapterDuo);
//        }else {
//            adapterNormal = new GoodsItemRvAdapter(context, titleList);
//            GridLayoutManager manager = new GridLayoutManager(context, 2);
//            manager.setOrientation(GridLayoutManager.VERTICAL);
//            rv.setLayoutManager(manager);
//            rv.setAdapter(adapterNormal);
//        }
//        container.addView(view);
//        return view;
//    }
//
//    private void initData() {
//
//    }

}
